#include<stdio.h>
#include<stdlib.h>

struct NUM
{
	int dig;
	struct NUM *next;
};

int Insert(struct NUM **head,int input);
int del_sum(struct NUM *head);
int main(void)
{
	int N,L,M,start,stop,del,flag,times;
	struct NUM *num=NULL;
	
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	{
		scanf("%d%d",&L,&M);
		times=0;
		for(int j=0;j<M;j++)
		{
			scanf("%d%d",&start,&stop);
			for(int k=start;k<=stop;k++)
			{
				flag=Insert(&num,k);
				if(flag==0)
				{
					times++;
				}
			}
		}
		printf("%d\n",L-times+1);
		num=NULL;
	}
	
	
	return 0;
}
int Insert(struct NUM **head,int input)
{
	struct NUM *temp,*fresh;
	
	temp=*head;
	while(temp!=NULL&&temp->dig!=input)
	{
		temp=temp->next;
	}
	
	if(temp==NULL)
	{
		fresh=(struct NUM *)malloc(sizeof(struct NUM));
		fresh->dig=input;
		
		if(*head!=NULL)
		{
			temp=*head;
			*head=fresh;
			fresh->next=temp;
		}
		else
		{
			*head=fresh;
			fresh->next=NULL;
		}
		return 0;
	}
	return 1;
}
int del_sum(struct NUM *head)
{
	int sum=0;
	struct NUM *temp;
	while(temp!=NULL)
	{
		temp=temp->next;
		sum++;
	}
	return sum;
}
